package com.czb.seckill.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: 陈正彬
 * 消息的接收者
 */
@Service
@Slf4j
public class MQReceiver {

    @Resource
    private RabbitTemplate rabbitTemplate;

    //方法 接收消息
    @RabbitListener(queues = "queue")
    public void receive(Object msg) {
        log.info("queue接收到消息-->" + msg);
    }

    //方法 接收消息
    @RabbitListener(queues = "queue_fanout1")
    public void receive1(Object msg) {
        log.info("queue_fanout1接收到消息-->" + msg);
    }

    //方法 接收消息
    @RabbitListener(queues = "queue_fanout2")
    public void receive2(Object msg) {
        log.info("queue_fanout2接收到消息-->" + msg);
    }

    //方法 接收消息
    @RabbitListener(queues = "queue_direct1")
    public void queue_direct1(Object msg) {
        log.info("queue_direct1接收到消息-->" + msg);
    }

    //方法 接收消息
    @RabbitListener(queues = "queue_direct2")
    public void queue_direct2(Object msg) {
        log.info("queue_direct2接收到消息-->" + msg);

    }

    //方法 接收消息
    @RabbitListener(queues = "queue_topic01")
    public void queue_topic01(Object msg) {
        log.info("queue_topic01接收到消息-->" + msg);

    }

    @RabbitListener(queues = "queue_topic02")
    public void queue_topic02(Object msg) {
        log.info("queue_topic02接收到消息-->" + msg);

    }

}
